package com.heima.admin.controller.v1;


import com.heima.admin.service.AdSensitiveService;
import com.heima.apis.admin.AdSensitiveControllerApi;
import com.heima.model.admin.dtos.SensitiveDto;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 敏感词信息表 前端控制器
 * </p>
 *
 * @author liulei
 * @since 2021-01-08
 */
@RestController
@RequestMapping("/api/v1/sensitive")
@Api(tags = "敏感词管理")
public class AdSensitiveController implements AdSensitiveControllerApi {

    @Autowired
    private AdSensitiveService adSensitiveService;
    /**
     * 查询
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/list")
    @ApiOperation(value = "敏感词查询")
    public ResponseResult list(@RequestBody SensitiveDto dto) {
        return adSensitiveService.list(dto);
    }

    /**
     * 新增
     *
     * @param adSensitive
     * @return
     */
    @Override
    @PostMapping("/save")
    @ApiOperation(value = "敏感词新增")
    public ResponseResult insert(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.insert(adSensitive);
    }

    /**
     * 修改
     *
     * @param adSensitive
     * @return
     */
    @Override
    @PostMapping("/update")
    @ApiOperation(value = "敏感词内容修改")
    public ResponseResult update(@RequestBody AdSensitive adSensitive) {
        return adSensitiveService.update(adSensitive);
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Override
    @DeleteMapping("/del/{id}")
    @ApiOperation(value = "通过id删除敏感词")
    public ResponseResult delete(@PathVariable("id") Integer id) {
        return adSensitiveService.delete(id);
    }

    /**
     * 查询所有敏感词  评论审核远程调用  不分页
     *
     * @return
     */
    @Override
    @GetMapping("findall")
    public List<String> findAllSensitive() {
        return adSensitiveService.findAllSensitive();
    }
}
